<!doctype  html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
	<title>关于校科联</title>
<style type="text/css">
       body{
               background: url("image/6_bg.png");
               background-size: 100% 100%;
               background-repeat: no-repeat;
               min-height:450px;
               width: 100%;
               padding-bottom:20px;
       }
       p span{
           font-weight: bold;
           font-size:18px;
       }
       form{
       	margin: 0 auto;
        margin-top: 60px;
       	width: 700px;
       	position: relative;
       }
       textarea{
       	resize:none;
       	height:350px;
       	width:700px;   
       }
       .button{
       	   display: inline-block;
       	   height: 28px;
       	   width: 80px;
       	   margin-right:15px;
       	   float:right;
       }
    
</style>
</head>
<body>
	<form>
         <select>
                <option>关于校科联</option>
                <option>历届成员</option>
                <option>校科联章程</option>
                <option>CI系统</option>
         </select>
         <input type="button" id="submit" value="提交" class="button">
         <a class="button" style="position:relative;left:20px;top:3px;" href="content_mag.html">返回</a>
		     <textarea rols="10" rows="5" id="textarea"></textarea>

	</form>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script charset="utf-8" src="js/kindeditor/lang/zh_CN.js"></script>
<script type="text/javascript" src="js/kindeditor/kindeditor-min.js"></script>
<script type="text/javascript" src="../public/js/serverIp.js"></script>
<script type="text/javascript">
        var editor;
        KindEditor.ready(function(K){
        	 K.create("#textarea",{
				      uploadJson : 'js/kindeditor/php/upload_json.php', //指定上传图片的服务器端程序
				      allowUpload : true,
					    fileManagerJson:"jskindeditor/php/file_manager_json.php",
					    allowFileManager : true,
				      urlType : 'absolute',
				      resizeType : 0,  //文本框不可拖动
				        
				        afterCreate : function(){ //kindeditor创建后，将编辑器的内容设置到原来的textarea控件里
				               this.sync();   
				        },
				        afterChange: function(){ //编辑器内容发生变化后，将编辑器的内容设置到原来的textarea控件里
				               this.sync();   
				        },
				        afterBlur : function(){ //编辑器聚焦后，将编辑器的内容设置到原来的textarea控件里
				            this.sync(); 
				        }  
		          })

        })

         var array=window.location.href.split("?");
         var substr=array[1].split("&");
         var datastr="type=COLUMN&bool=false&columnId="+substr[1]+"&modelId="+substr[0];
         var single_id;

         $.post(serverIp+"/Scauaie.com/artical/showAll",datastr,function(data){
               var dataobj=JSON.parse(data);
               single_id=dataobj[0].single_id;
               KindEditor.html('#textarea',dataobj[0].content);//给文本框内赋值
         },"html")

          $("#submit").click(function(){
              var data={
                  "type":"COLUMN",
                  "bool":false,
                  "modelId":substr[0],
                  "columnId":substr[1],
                  "content":$("#textarea").val(),
                  "id":single_id,
                  "single_id":single_id

              };

               if(!$("#textarea").val()){
                      alert("请先填写完整");
               }else{
                  $.post(serverIp+"/Scauaie.com/artical/edit",{"data":JSON.stringify(data)},function(data){
                        var dataobj=JSON.parse(data);
                        if(dataobj.bool=="true"){
                            if(confirm("提交成功，留在本页面？")){
                               var href=window.location.href;
                               window.location.href=href;
                            }else{
                               window.location.href="content_mag.html";
                            }
                        }else{
                           alert("提交失败，请重新尝试.")                          
                        } 
                   },"html")
               }
         })
         
</script>
</body>
</html>	